<div class="window project-add">
	<div class="title">Edit project</div>
	<div class="content">
	<?php echo $this->Form->create('Project', array('url' => '/projects/edit'));?>
		<?php
			echo $this->Form->input('id');
			echo $this->Form->input('name');
			echo $this->Form->input('desc');
			?>
			<table>
			<tr>
				<td>
					<?php echo $this->Form->input('User', array('options' => $users_in_project, 'id' => 'project-members')); ?>
				</td>
				<td>
					<table>
					<tr><td><button id="add-member"><</button></td></tr>
					<tr><td><button id="remove-member">></button></td></tr>
					</table>
				</td>
				<td>
					<?php echo $this->Form->input('User', array('options' => $other_users, 'label' => false, 'name' => 'users', 'id' => 'project-users')); ?>
				</td>
			</tr>
			</table>
	<?php echo $this->Form->end(__('Submit', true));?>
	</div>
</div>
<script>
	
	$("#add-member").click(function(){
		$("#project-users option:selected").each(function(){
			$("#project-members").append(this);
		});
		return false;
	});
	
	$("#remove-member").click(function(){
		$("#project-members option:selected").each(function(){
			$("#project-users").append(this);
		});
		return false;
	});
	
	$(".project-add form").submit(function(){
		
		$("#project-members option").each(function(){
			$(this).attr("selected", "selected");
		});
		
	});
	
</script>